package com.jjyu.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jjyu.entity.Restaurant;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RestaurantMapper extends BaseMapper<Restaurant> {
    @Select("select * from restaurant")
    public List<Restaurant> getAllRestaurant();

    @Select("SELECT * FROM restaurant " +
            "WHERE (POW(latitude - #{latitude}, 2) + POW(longitude - #{longitude}, 2)) < #{radius}")
    List<Restaurant> findRestaurantsByLocation(@Param("latitude") double latitude,
                                               @Param("longitude") double longitude,
                                               @Param("radius") double radius);

}
